package net.bplaced.streetfighter.lib.async.task;

import java.util.Date;

import net.bplaced.streetfighter.lib.model.Match;
import net.bplaced.streetfighter.lib.service.MatchServiceImpl;
import net.bplaced.streetfighter.lib.utils.CallBack;
import net.bplaced.streetfighter.lib.utils.ServiceReturnPackage;
import android.content.Context;

/**
 * @author Sebastian Hoffmann <bo.hoffi@googlemail.com>
 */
public class MatchLoaderTask
        extends AbstractLoaderTask<Date, ServiceReturnPackage<Match[]>> {

    public MatchLoaderTask(Context context, String progressMessage, CallBack<ServiceReturnPackage<Match[]>> onFinished) {

        super(context, progressMessage, onFinished);
    }

    @Override
    ServiceReturnPackage<Match[]> performInBackground(Date... dates) {

        if (dates.length != 1) {
            return null;
        }

        return new MatchServiceImpl().loadMatchesViaPOST(dates[0]);
    }
}